#!/usr/bin/env python
# coding: utf-8

# from .xxx_element import xxx_element
import os
import re

PC_SHELL = 200000000

class pc_base():
    OPTIONS = []
    def __init__(self):
        # xxx_element.__init__(self)
        return None
        
    def connect(self, ip, slot, port, usr=None, pwd=None):
        return True
        
    def disconnect(self, ip=None, port=None):
        return True

    def send(self, cmd, rtn_flag='', ip=None, slot=None, port=None):
        if type(cmd) != str:
            return False
        if re.match(r"^\s*$", cmd)!=None:
            return True
        os.system(cmd + '>pcbase_temp')
        file = open('pcbase_temp')
        rtn = file.read()
        file.close()
        os.remove('pcbase_temp')
        self.logger.info(cmd)
        self.logger.info(rtn)
        if rtn.find(rtn_flag) == -1:
            return False
        return True
        
    def send_only(self, cmd, ip=None, slot=None, port=None):
        if type(cmd) != str:
            return False
        if re.match(r"^\s*$", cmd)!=None:
            return True
        os.system(cmd)
        self.logger.info(cmd)
        return True
        
    def send_rtn_str(self, cmd, ip=None, slot=None, port=None):
        if type(cmd) != str:
            return ' '
        if re.match(r"^\s*$", cmd)!=None:
            return ' '
        os.system(cmd + '>pcbase_temp')
        file = open('pcbase_temp')
        rtn = file.read()
        file.close()
        os.remove('pcbase_temp')
        self.logger.info(cmd)
        self.logger.info(rtn)
        return rtn

if __name__ == "__main__" :
    case = pc_base()
    print (case.send_rtn_str(""))
    print ("end")
    
    